import 'package:get/get.dart';
import 'package:share_fit/app/helper/ext/tr_ext.dart';
import 'package:share_fit/app/models/home/date_type_enum.dart';
import 'package:share_fit/generated/locales.g.dart';

import 'state.dart';

class FatigueLogic extends GetxController {
  final FatigueState state = FatigueState();

  goBack() {
    Get.back();
  }

  changeDateType({type, int? selectedIndex}) {
    state.selectedDateType.value = type;
    state.dateTypeBarIndex = selectedIndex ?? 0;
    update(['fatigue_date_type', 'date_type_bar']);
  }

  String getCycleRadioTitle() {
    if (state.selectedDateType.value == DateType.day) {
      return LocaleKeys.spo2_day_cycle_ratio_title.ts;
    } else if (state.selectedDateType.value == DateType.week) {
      return LocaleKeys.spo2_week_cycle_ratio_title.ts;
    } else if (state.selectedDateType.value == DateType.month) {
      return LocaleKeys.spo2_month_cycle_ratio_title.ts;
    } else {
      return LocaleKeys.spo2_year_cycle_ratio_title.ts;
    }
  }
}
